import { UP_DATA_USER_INFO, DEL_USER_INFO, UP_DATA_INVITE, WX_AUTH } from '../types/userInfo'

const INITIAL_STATE = {
  user: {},
  invite: {},
  wxAuth: {}
}

export default function counter(state = INITIAL_STATE, action) {
  switch (action.type) {
    case UP_DATA_USER_INFO:
      return {
        ...state,
        user: Object.assign(state.user, action.payload)
      }
    case DEL_USER_INFO:
      return {
        ...state,
        user: {}
      }
    case UP_DATA_INVITE:
      return {
        ...state,
        invite: Object.assign(state.invite, action.payload)
      }
    case WX_AUTH:
      return {
        ...state,
        wxAuth: Object.assign(state.wxAuth, action.payload)
      }
    default:
      return state
  }
}
